package com.example.mytayunapi.Controller;

import com.example.mytayunapi.Entity.ComplaintsInfo;
import com.example.mytayunapi.Service.ComplaintsInfoService;
import com.example.mytayunapi.Vo.ShareUserInfo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("appeal")
public class ComplaintsInfoController {
    //分页
    @GetMapping("/page")
    public PageInfo<ComplaintsInfo> pageInfo(@RequestParam Integer page, @RequestParam Integer size){
        return complaintsInfoService.getPageInfo(page,size);
    }

    @Autowired
    private ComplaintsInfoService complaintsInfoService;
    @GetMapping("/data")
    public List<ComplaintsInfo> getComplaintsInfo(){
        return complaintsInfoService.getComplaintsInfo();
    }
    @GetMapping("/querydata")
    public List<ComplaintsInfo> queryComplaintsInfo(Integer Complaint_id){
        List<ComplaintsInfo> Com = null;
        if(Complaint_id==null){
            Com = complaintsInfoService.getComplaintsInfo();
        }else {
            Com = complaintsInfoService.getComplaintsInfoById(Complaint_id);
        }
        return Com;
    }

    @PostMapping("/updata")
    public Integer updateComplaintsInfo(@RequestBody ComplaintsInfo complaintsInfo){
        return complaintsInfoService.updateComplaintsInfo(complaintsInfo);
    }

    @GetMapping("del/{id}")
    private Integer delStudentInfoById(@PathVariable Integer id) {
        return complaintsInfoService.deleteByID(id);
    }

}
